package designPattern.factory.simpleFactory.improve;

import designPattern.factory.simpleFactory.common.ChessPizza;
import designPattern.factory.simpleFactory.common.GreekPizza;
import designPattern.factory.simpleFactory.common.Pizza;

//简单工厂类
public class SimpleFactory {

    //根据orderType返回对应的Pizza 对象
    public Pizza creatPizza(String orderType){
        Pizza pizza = null;

        System.out.println("使用简单工厂模式");
        if(orderType.equals("greek")){
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        }else if(orderType.equals("chess")){
            pizza = new ChessPizza();
            pizza.setName("奶酪披萨");
        }

        return pizza;
    }
}
